package controller;

import Service.ProService;
import Service.impl.ProServiceimpl;
import pojo.Pro;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.8.28 下午 15:25
 */
@javax.servlet.annotation.WebServlet("/findAllpro")
public class ProServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        //调用Service
        ProService proService = new ProServiceimpl();
        List<Pro> list = proService.getAllProduct();

        //将list存储在request域中
        request.setAttribute("list",list);

        //请求转发到list.jsp
        request.getRequestDispatcher("/list.jsp").forward(request,response);



    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request,response);

    }
}
